package com.donggua.aichebao.commonui.home;

import android.content.Context;
import android.content.res.TypedArray;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.TextView;

import com.donggua.aichebao.commonui.R;

/**
 * Created by Administrator on 2017-08-12.
 */

public class HomeThreeTextViewLayout extends FrameLayout{
    private TextView tvFirst;
    private TextView tvSecond;
    private TextView tvThird;
    private View mainView;
    private String strFirst;
    private String strSecond;
    private String strThree;
    public HomeThreeTextViewLayout(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        LayoutInflater inflater = LayoutInflater.from(context);
        mainView = inflater.inflate(R.layout.dg_home_page_three_textview, this,
                true);
        TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.CustomThreeTextView);
        strFirst = ta.getString(R.styleable.CustomThreeTextView_customFirstText);
        strSecond = ta.getString(R.styleable.CustomThreeTextView_customSecondText);
        strThree = ta.getString(R.styleable.CustomThreeTextView_customThreeText);
        ta.recycle();
    }
    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
        initTextView();
    }

    protected  void initTextView(){
        tvFirst = (TextView)mainView.findViewById(R.id.tvFirst);
        tvSecond = (TextView)mainView.findViewById(R.id.tvSecond);
        tvThird = (TextView)mainView.findViewById(R.id.tvThree);
        tvFirst.setText(strFirst);
        tvSecond.setText(strSecond);
        tvThird.setText(strThree);
    }

    public void setFistText(String text){
        tvFirst.setText(text);
    }

    public void setSecondText(String text){
        tvSecond.setText(text);
    }

    public void setThirdText(String text){
        tvThird.setText(text);
    }
}
